#ifndef JsonQueryFactory_h
#define JsonQueryFactory_h

#include "IJsonQuery.h"
#include <QSharedPointer>
#include "query.h"
#include <map>

//enum QueryType should be created in server.cpp

class JsonQueryFactory
{
  std::map<QueryType, QSharedPointer<IJsonQuery> > types;
public:
  template <class T>
  void reg(QueryType qq)
  {
    types[qq]=QSharedPointer<IJsonQuery>(new T());
  }

  QSharedPointer<IJsonQuery> getJsonQuery(const Query& q,const std::stringstream& s)
  {
    types[q.getType()]->init(s);
    return types[q.getType()];
  }
};

#endif /* JsonQueryFactory_h */
